package com.learn.builder.innerClass;

import com.learn.builder.base.Body;
import com.learn.builder.base.Foot;
import com.learn.builder.base.Hand;
import com.learn.builder.base.Head;

/**
 * <p>项目名称: design-pattern </p>
 * <p>文件名称: Man </p>
 * <p>描述: TODO </p>
 *
 * @author zhousiqi
 * @version v0.0.1
 * @since 2018/10/24 10:57
 */
public class Man {

    private final Head head;
    private final Body body;
    private final Hand hand;
    private final Foot foot;

    private Man(Builder builder) {
        this.head = builder.head;
        this.body = builder.body;
        this.hand = builder.hand;
        this.foot = builder.foot;
    }

    @Override
    public String toString() {
        return "Man{" +
                "head=" + head +
                ", body=" + body +
                ", hand=" + hand +
                ", foot=" + foot +
                '}';
    }

    public static class Builder{
        private Head head;
        private Body body;
        private Hand hand;
        private Foot foot;

        public Builder() {
        }

        public Builder buildHead(Head head){
            this.head = head;
            return this;
        }

        public Builder buildBody(Body body){
            this.body = body;
            return this;
        }

        public Builder buildHand(Hand hand){
            this.hand = hand;
            return this;
        }

        public Builder buildFoot(Foot foot){
            this.foot = foot;
            return this;
        }

        public Man createMan(){
            return new Man(this);
        }
    }
}
